package com.leet.everyday;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class MaxnumOficecream {
    public int maxIceCream(int[] costs, int coins) {
       Arrays.sort(costs);
        int sum = 0;
        int cnt = 0;
        if(coins < costs[0]) return 0;
        for(Integer cost:costs){
            if(sum >= coins){
                if(sum > coins){
                    cnt--;
                }
                break;
            }
            sum += cost;
        }
        return cnt;
    }
}
